<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                Kuchařka - seznam receptů
            </ui:define>

            <ui:define name="heading">
                Seznam receptů
            </ui:define>

            <ui:define name="subheading">
                V této sekci si můžete prohlédnout recepty, postupy vaření a potřebné suroviny, případně vytvořit nový recept.
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <c:choose>
                        <c:when test="#{PrihlaseniView.logged}">
                            <p align="center" style="margin-bottom:30px">
                                <h:commandLink type="submit" class="btn btn-success" action="#{receptView.showReceptNew()}">
                                    <span class="glyphicon glyphicon-plus"></span> Nový recept
                                </h:commandLink>
                            </p>
                        </c:when>
                    </c:choose>
                    <hr></hr>
                
                
                
                <!-- ALTERNATIVNI FORMAT TABULKY -->
                
                    <h:dataTable value="#{receptView.allRecept}" var="value"
                                 class="table table-striped table-hover"
                    >
                        <h:column>
                            <f:facet name="header">Název</f:facet>
                            <h:commandLink action="#{receptView.showReceptDetail(value)}" value="#{value.nazev}" />
                        </h:column>

                        <h:column>
                            <f:facet name="header">Ingredience</f:facet>
                            <h:commandLink action="#{receptView.showReceptDetail(value)}">
                                <ui:repeat value="#{receptView.toList(value.seznamIngredienci)}" var="entry">
                                    <h:outputText escape="false" value="#{entry.key.nazev}"/>
                                    ,&nbsp;
                                </ui:repeat>
                            </h:commandLink>   
                        </h:column>
                        
                        <h:column>
                            <c:choose>
                                <c:when test="#{PrihlaseniView.logged}">
                                    <h:commandLink type="submit" class="btn btn-xs btn-primary" action="#{receptView.showReceptEdit(value)}">
                                        <span class="glyphicon glyphicon-pencil"/>Upravit
                                    </h:commandLink>

                                    <h:commandLink type="submit" class="btn btn-xs btn-danger">
                                        <span class="glyphicon glyphicon-remove"/>Smazat
                                    </h:commandLink>
                                </c:when>
                            </c:choose>
                        </h:column>
                    </h:dataTable>
                </h:form>
                 
                    
                <!-- KONEC ALTERNATIVNI TABULKY -->
                
                <!--
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>Název</th>
                            <th>Seznam ingrediencí</th>
                                                <th></th>
                        </tr>
                    </thead>
                    <ui:repeat value="#{receptView.allRecept}" var="value">
                    <tr style="cursor:pointer" onClick="location.href='recepty_detail.html'">
                        <td><h:commandLink action="#{receptView.showReceptDetail(value)}" value="#{value.nazev}" /></td>
                        <td>
                            <h:commandLink action="#{receptView.showReceptDetail(value)}">
                                <ui:repeat value="#{receptView.toList(value.seznamIngredienci)}" var="entry">
                                    <h:outputText escape="false" value="#{entry.key.nazev}"/>
                                    ,&nbsp;
                                </ui:repeat>
                            </h:commandLink>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="#{PrihlaseniView.logged}">
                                    <h:commandLink type="submit" class="btn btn-xs btn-primary" action="#{receptView.showReceptEdit(value)}">
                                        <span class="glyphicon glyphicon-pencil"/>Upravit
                                    </h:commandLink>
                                    <h:commandLink type="submit" class="btn btn-xs btn-danger">
                                        <span class="glyphicon glyphicon-remove"/>Smazat
                                    </h:commandLink>
                                </c:when>
                                <c:otherwise>
                                    <span/>
                                    <span/>
                                </c:otherwise>
                            </c:choose>
                        </td>
                    </tr>
                    </ui:repeat>
                </table>
            </h:form>-->
                
                 
            </ui:define>
            
            <ui:define name="breadcrumbs">
                <h:commandLink action="index" value="Kuchařka"/> > Seznam receptů
            </ui:define>

        </ui:composition>

    </body>
</html>
